//
//  UIButton+Extension.swift
//  sinaWeBoo
//
//  Created by Fly on 15/10/19.
//  Copyright © 2015年 Fly. All rights reserved.
//

import UIKit

extension UIButton{
    
    // 便利构造函数 设置Button基本属性
    /**
    设置button图片与背景图片
    
    :param: imageName 图片名
    :param: backImage 背景图片名
    
    :returns: button
    */
    convenience init(imageName: String,backImage: String?){
        self.init()
        
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        if let backgroundName = backImage {
            setBackgroundImage(UIImage(named: backgroundName), forState: .Normal)
            setBackgroundImage(UIImage(named: backgroundName + "_highlighted"), forState: UIControlState.Highlighted)
        }
        
        sizeToFit()
    }
    
    //
}